__author__ = 'bpatel'
import wx
import re
class Utils:
    def __init__(self):
        self.cfg = wx.Config('rokuRemote')
        
    def saveRokuAddress(self, address):
        self.cfg.Write("host", address)
    def getRokuAddress(self):
        if self.cfg.Exists('host'):
            return self.cfg.Read('host')
        else:
            raise Exception("Setting not found")
    def validateIP(self, ip):
        pattern = r"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
        if re.match(pattern, ip):
            return True
        else:
            return False
        
